import request from '@/api/request'
export function patients(data) {
  return request({
    url: '/emrweb/patient/page',
    method: 'post',
    data,
  })
}

export function awaitPatients(data) {
  return request({
    url: '/emrweb/patient/pageWait',
    method: 'post',
    data,
  })
}
export function patientInfo(params) {
  return request({
    url: '/emrweb/patient/queryInfo',
    method: 'get',
    params,
  })
}

export function patientDscInfo(params) {
  return request({
    url: '/emrweb/patient/queryUserInfo',
    method: 'get',
    params,
  })
}
export function save(data) {
  return request({
    url: '/emrweb/patient/save',
    method: 'post',
    data,
  })
}

export function lastSign(params) {
  return request({
    url: '/emrweb/patientSigns/queryPatientAllList',
    method: 'get',
    params,
  })
}

export function queryPage(data) {
  return request({
    url: '/emrweb/patientSigns/queryPage',
    method: 'post',
    data,
  })
}

export function addPatientSign(data) {
  return request({
    url: '/emrweb/patientSigns/save',
    method: 'post',
    data,
  })
}

//删除患者体征
export function delSigns(data) {
  return request({
    url: '/emrweb/patientSigns/remove',
    method: 'post',
    data,
  })
}
export function dayLastRecord(data) {
  return request({
    url: '/emrweb/patientSigns/queryGroupList',
    method: 'post',
    data,
  })
}

// 校验患者是否存在
export function queryPatient(data) {
  return request({
    url: '/emrweb/patient/queryPatient',
    method: 'post',
    data,
  })
}

// 修改用户信息
export function modify(data) {
  return request({
    url: '/emrweb/patient/modify',
    method: 'post',
    data,
  })
}

// 加载患者历史病历
export function loadEmrHistory(data) {
  return request({
    url: '/emrweb/medicalRecord/page',
    method: 'post',
    data,
  })
}

/**
 * 加载患者的历史就诊[历史病历]树形
 * @param {*} data
 * @returns
 */
export function loadHistoricalVisitTree(data) {
  return request({
    url: '/emrweb/medicalRecord/getPatientVisGroup',
    method: 'post',
    data,
  })
}
// 加载患者历史病历
export function modifyVisit(data) {
  return request({
    url: '/emrweb/patient/modifyVisit',
    method: 'post',
    data,
  })
}

/**
 * 加载患者历史病历及详细数据
 */
export function loadEmrFullHistory(data) {
  return request({
    url: '/emrweb/medicalRecord/queryPageDetailed',
    method: 'post',
    data,
  })
}

/**
 * 加载呼吸峰流速
 * @param {*} data
 * @returns
 */
export function loadPefHistory(data) {
  return request({
    url: '/emrweb/emrTracking/getPefPage',
    method: 'post',
    data,
  })
}

/**
 * 加载呼吸峰流速值图表
 */
export function getPefChartData(data) {
  return request({
    url: '/emrweb/emrTracking/getPefStatistics',
    method: 'post',
    data,
  })
}

/**
 * 填写呼吸峰流速
 * @param {*} data
 * @returns
 */
export function savePef(data) {
  return request({
    url: '/emrweb/emrTracking/savePef',
    method: 'post',
    data,
  })
}

/**
 * 加载视频上传
 * @param {*} data
 * @returns
 */
export function getVideoUploadList(data) {
  return request({
    url: '/emrweb/emrTracking/getVideoPage',
    method: 'post',
    data,
  })
}

/**
 * 视频列表医生回复患者或修改备注
 */
export function relyVideoMsg(data) {
  return request({
    url: '/emrweb/emrTracking/saveVideo',
    method: 'post',
    data,
  })
}

/**
 * 加载视频上传
 * @param {*} data
 * @returns
 */
export function getBSList(data) {
  return request({
    url: '/emrweb/emrTracking/getBreathSoundPage',
    method: 'post',
    data,
  })
}

/**
 * 视频列表医生回复患者或修改备注
 */
export function relyBSMsg(data) {
  return request({
    url: '/emrweb/emrTracking/saveBreathSound',
    method: 'post',
    data,
  })
}

/**
 * 加载打卡日历数据
 */
export function loadMedicationRecord(data) {
  return request({
    url: '/emrweb/emrTracking/getPatientDrugRecordStatistics',
    method: 'post',
    data,
  })
}

/**
 * 加载当前打开详细数据
 */
export function loadMedicationRecordInfo(params) {
  return request({
    url: '/emrweb/emrTracking/getPatientDrugDayRecord',
    method: 'get',
    params,
  })
}

// 根据患者id查询绑定该患者的用户列表
export function getBindPatientList(params) {
  return request({
    url: '/emrweb/patient/getBindPatientList',
    method: 'get',
    params,
  })
}

/**
 * 查询患者诊疗状态
 * @param {*} data  { patientId, medicalRecordId}
 * @returns
 */
export function getEmrStatus(params) {
  return request({
    url: '/emrweb/patient/queryPatientVisStatus',
    method: 'get',
    params,
  })
}

/**
 * 查询第三方/医院患者数据数据
 * @param {*} data  { cardNo }
 */
export function getHospitalData(params) {
  return request({
    url: '/emrweb/patient/opUpRptPatient',
    method: 'get',
    params,
  })
}

/**
 * 加载旧患者数据
 */
export function loadOldEmr(params) {
  return request({
    url: '/emrweb/medicalRecord/queryOldMedicalRecord',
    method: 'get',
    params,
  })
}

/**
 * 进入呼气峰流速加载初始化数据（日间变异率）
 * 保存的时候需要上传该数据
 * @param {*} params
 */
export function getInitPef(params) {
  return request({
    url: '/emrweb/emrTracking/getInitPef',
    method: 'get',
    params,
  })
}

/**
 * 删除患者
 * @param {Number} patientId 患者ID
 * @returns
 */
export function deletePatient(patientId) {
  return request({
    url: `/emrweb/patient/delete/${patientId}`,
    method: 'get',
  })
}
